/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/

#pragma once

#include <string>
#include <memory>
#include <vector>
#include <db/db_types.h>

namespace test_wrappers { namespace storage {

namespace b = test_wrappers;

enum comparison_operator
{
    equal_operator,
    equal_or_great_than_operator
};

enum index_attributes
{
    default_index = 0x00,
    primary_index = 0x01,
    unique_index = 0x02
};

enum index_field_attributes
{
    default_index_field = 0x00,
    ascending_index_field = 0x01
};

// forward declarations
struct field_definition
{
    field_definition(){}
    virtual ~field_definition(){}

    // setters
    virtual void setFixed(bool fixed) = 0;
    virtual void setAutoIncrement(bool autoIncrement) = 0;
    virtual void setMaxBufferSizeInBytes(unsigned int sizeInBytes) = 0;

    // getters
    virtual field_id userId() const = 0;
    virtual std::wstring name() const = 0;
    virtual field_type type() const = 0;
    virtual bool fixed() const = 0;
    virtual bool autoIncrement() const = 0;
    virtual unsigned int codePage() const = 0;
    virtual unsigned long maxBufferSizeInBytes() const = 0;

    // operations
    virtual std::shared_ptr<field_definition> clone() const = 0;
};

struct field_instance
{
    field_instance(){}
    virtual ~field_instance(){}

    // getters
    virtual field_id fieldInstanceId() const = 0;
    virtual field_id userFieldId() const = 0;
    virtual std::wstring name() const = 0;
    virtual field_type type() const = 0;
    virtual bool fixed() const = 0;
    virtual bool autoIncrement() const = 0;
    virtual unsigned int codePage() const = 0;
    virtual unsigned long maxBufferSizeInBytes() const = 0;
};

template<class T>
class field_definition_t;

struct field_value
{
    field_value(){}
    virtual ~field_value(){}

    // getters
    virtual size_t size() = 0;
    virtual field_id fieldInstanceId() = 0;
    virtual void* buffer() = 0;
    virtual bool appendOnUpdate() = 0;
    virtual void setAppendOnUpdate(bool append) = 0;
    virtual bool set() = 0;
};

template<class T>
class field_value_t;

}} // namespace test_wrappers::storage
